#include "ElapsedTimer.h"

using namespace SG::Base;

//=============================================================================
// Timer

ElapsedTimer::ElapsedTimer ()
{
    start ();
}

void ElapsedTimer::start ()
{
    t1 = std::chrono::system_clock::system_clock::now ();
    t2 = t1;
}

int64_t ElapsedTimer::elapsed ()
{
    t2 = std::chrono::system_clock::now ();

    int64_t dt = std::chrono::duration_cast<std::chrono::milliseconds> (t2 - t1).count ();
    return dt;
}

int64_t ElapsedTimer::restart ()
{
    auto dt = elapsed ();
    start ();
    return dt;
}